<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{
    /**
     * Seed the application's database.
     *
     * @return void
     */
    public function run()
    {
        // \App\Models\User::factory(10)->create();

        $seeders = $this->getSeeders();

        $this->call($seeders);
    }

    protected function getSeeders()
    {
        $files = glob(__DIR__ . '/*Seeder.php');

        // 剔除 DatabaseSeeder.php
        $files = array_diff($files, [__DIR__ . '/DatabaseSeeder.php']);

        $seeders = [];
        foreach ($files as $file) {
            $name = basename($file, '.php');
            $seeders[] = "Database\\Seeders\\{$name}";
        }

        return $seeders;
    }
}
